import java.util.Scanner;

public class 求最大公因数和最小公倍数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
//        System.out.println(lcm(a,b));
        System.out.println(gcd2(a,b));
    }
    // 最小公倍数
    static int lcm(int a,int b){
        return a*b/gcd(a,b);
    }
    // 最大公因数
    static int gcd(int a,int b){
        int t;
        if (a<b){
            t = a;
            a = b;
            b = t;
        }
        if (b==0){
            return a;
        }
        return gcd(b,a%b);
    }
    static int gcd2(int a,int b){
        return b==0?a:gcd2(b,a%b);
    }
}
